-------------------------------------------------------------------------------
Sample Name: CodeLibrary

Description: A code librarian that allows you to store fragments written in 
             any programming language. It even comes with a small database of 
             useful VB6, VB.NET, ASP.NET and Java snippets. VB Migration Partner 
             converts its 10 forms and 1 module (1200 total lines of code) in 
             a blink

Download URL: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=52772&lngWId=1
-------------------------------------------------------------------------------

IMPORTANT NOTE
The first step to ensure that you can migrate the VB6 project to VB.NET is 
loading the original project in the Visual Basic 6 IDE, run it to ensure that 
it works fine, that all the required type libraries are installed, and that all 
file paths are correct. 
Regardless of whether you edited the source code in any way, you should save 
the VB6 project: this save operation ensures that the .vbp file includes  
the correct path and version of referenced type libraries. 
After saving the project, it's usually a good idea to compile the VB6 project
to an executable, to detect any VB6 compilation errors that would appear under 
VB.NET as well. 
(If you don't recompile the project VB Migration Partner will display a warning 
when you later load the project.)

This sample uses an Access database file called STOREDFILE.MDB. You can have 
VB Migration Partner copy the file to the migrated solution folder by inserting
an AddDataFile pragma at the top of the Module1.bas:

'##AddDataFile STOREDFILE.MDB


This sample highlights a difference between VB6 and VB.NET. VB6 objects that
are declared with "As New" use "lazy instantiation": they are instantiated only
when they are referenced in code, not when they are declared. Also, if such 
references are set to Nothing, they are automatically re-istantiated the next
time they are referenced in code. Conversely, VB.NET objects declared with "As New"
are instantiated when then are declared and are not automatically re-instantiated
if they are set to Nothing and then referenced again in code.

You can have VB Migration Partner generate VB.NET code that behaves like the 
original VB6 code by adding three AutoNew pragmas.


In Module1: 

Option Explicit

Global strLang                  As TextBox

Global rs_folder                As New ADODB.Recordset
Global rs_files                 As New ADODB.Recordset

'##rsGetLang.AutoNew True
Global rsGetLang                As New ADODB.Recordset
'##connGetLang.AutoNew True
Global connGetLang              As New ADODB.Connection
'##cn.AutoNew True
Global cn                       As New ADODB.Connection


In Form8:

Option Explicit

Dim rs As New ADODB.Recordset
'##cn1.AutoNew True
Dim cn1 As New ADODB.Connection




VB Migration Partner typically delivers many warnings that are related to 
code analysis as well as suggestions about how you can improve the original 
VB6 code before converting it to VB.NET. 
You can suppress these warnings by adding the following project-level pragmas 
at the top of any of the file that make up the project:

'##project:DisableMessages CodeAnalysis
